package com.margo.project.web.mvcconfig.exceptionresolver;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.margo.project.web.utils.ResultUtils;
import com.margo.project.web.utils.ResultVO;

/**
 * https://www.cnblogs.com/FraserYu/p/11380878.html
 * @author fangxingbang
 *
 */
@ControllerAdvice
public class ExceptionHandlerAdvice {
	
	private Logger logger=LoggerFactory.getLogger(this.getClass());
	
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public ResultVO handleException(Exception ex) {
		logger.error(ex.getMessage(), ex);
		return ResultUtils.fail(ex.getMessage());
	}
}
